import requests as req
import json
from codes.commons.common_utils import get_seconds_stamp
from codes.commons.configs import easiest_common_headers as common_headers
from codes.match6.encrypted_ass import EncryptedAss

# 注意：参数时效性只有5秒！！！

url = 'http://match.yuanrenxue.com/api/match/6'


def request_pages():
    ass = EncryptedAss()
    price_total = 0
    for p in range(1, 6):
        tt = str(get_seconds_stamp())
        m = ass.encrypt(tt, 1)
        params = {
            "page": p,
            "m": m,
            "q": "1-" + tt + "|"
        }
        res = req.get(url=url, params=params, headers=common_headers)
        page_content = res.text
        print(f'获取第【{p}】页数据：{page_content}')
        con_obj = json.loads(page_content)
        for d in con_obj['data']:
            price_total += d['value']

    return price_total * 24


if __name__ == '__main__':
    t = request_pages()
    print('全部中奖的总金额:', t)
